//
//  SubjectSecondParser.m
//  ITrip
//
//  Created by dllo on 15/5/25.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "SubjectSecondParser.h"

@implementation SubjectSecondParser

-(instancetype)init
{
    self = [super init];
    if (self) {
        self.id = @"";
        self.name = @"";
        self.image_url = @"";
        self.title = @"";
        
    }
    return self;
}


- (NSMutableArray *)getParser:(NSData *)data
{
    
    ///外层字典
    NSMutableArray *dataArray = [NSMutableArray array];
    
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
    self.name = [dic objectForKey:@"name"];
    self.id = [dic objectForKey:@"id"];
    self.image_url = [dic objectForKey:@"image_url"];
    self.title = [dic objectForKey:@"title"];
    //取数组
    NSArray *array = [dic objectForKey:@"article_sections"];
    //取出数组中的所有字典，放进secondModel
    for (NSDictionary *dic in array) {
        SubjectSecondModel *secondModel = [[SubjectSecondModel alloc] init];
        [secondModel setValuesForKeysWithDictionary:dic];
        [dataArray addObject:secondModel];
//        NSLog(@"%@", secondModel.title);
    }

     return dataArray;
}
@end
